<template>
  <el-dialog

      title="请选择需要迁移的平台"
      show-close width="50%"
      :visible.sync="dialogVisible"
      :before-close="handleClose"
      append-to-body>
    <avue-form v-model="formModel" :option="formOption" @submit="submit"></avue-form>
  </el-dialog>
</template>

<script>
import {baseUrl} from "../../../config/env";
import {platformMigration} from "@/api/tpp/thirdPartyPlatformConfigApi";

export default {
  name: "platformUserMigration",
  computed: {
    formOption() {
      return {
        menuBtn: true,
        menuPosition: "right",
        column: [
          {
            label: "旧平台",
            prop: "oldPlatformId",
            type: "select",
            dicUrl: baseUrl + "/tpp/thirdPartyPlatformConfig/getAllConfig",
            span: 24,
            props: {
              label: "name",
              value: "id",
            },
            rules: [{
              required: false,
              trigger: "blur"
            }]
          },
          {
            label: "新平台",
            prop: "newPlatformId",
            type: "select",
            dicUrl: baseUrl + "/tpp/thirdPartyPlatformConfig/getAllConfig",
            span: 24,
            props: {
              label: "name",
              value: "id",
            },
            rules: [{
              required: false,
              trigger: "blur"
            }]
          }
        ]
      }
    }
  },
  data() {
    return {
      dialogVisible: false,
      formModel: {}
    }
  },
  methods: {
    handleClose() {
      this.dialogVisible = false;
      this.formModel = null;
    },
    show(row) {
      this.formModel = {};
      this.formModel.oldPlatformId = row.id;
      this.dialogVisible = true;
    },
    submit(val,done) {
      platformMigration(val).then(res => {
        this.$message.success("操作成功");
        this.handleClose();
      }).finally(()=>{
        done();
      })
    }
  }
}
</script>

<style scoped>

</style>